package com.gem.talkbase.util;  
  
import com.gem.talkbase.widget.DisplayNextView;

 
import android.app.Activity;
import android.util.Log;  
import android.view.Display;
import android.view.ViewGroup;  
import android.view.animation.AccelerateInterpolator;  
  
public class RotationHelper {  
      
    DisplayNextView displayNext;  
    Activity activity;
      
    public RotationHelper(Activity con,int order){  
    	this.activity=con;
        displayNext = new DisplayNextView(con, order);  
    }  
      



	public void applyFirstRotation(ViewGroup layout,float start, float end) {  
        // Find the center of the container  
    	Display display = activity.getWindowManager().getDefaultDisplay();
        final float centerX = display.getWidth() / 2.0f;  
        final float centerY = display.getHeight() / 2.0f;  
        Log.i("centerX =" + centerX, "centerX");  
        Log.i("centerY =" + centerY, "centerY");  
         System.out.println(centerX+"=================================="+centerY);
        // Create a new 3D rotation with the supplied parameter  
        // The animation listener is used to trigger the next animation  
        final Rotate3dAnimation rotation = new Rotate3dAnimation(start, end,  
                centerX, centerY, 310.0f, true);  
        rotation.setDuration(1000);  
        rotation.setFillAfter(true);  
        rotation.setInterpolator(new AccelerateInterpolator());  
        rotation.setAnimationListener(displayNext);   
      //  System.out.println(layout);
        layout.startAnimation(rotation);  
    }  
      
    public void applyLastRotation(ViewGroup layout,float start, float end) {  
        // Find the center of the container  
    	Display display = activity.getWindowManager().getDefaultDisplay();
        final float centerX = display.getWidth() / 2.0f;  
        final float centerY = display.getHeight() / 2.0f;  
        Log.i("centerX =" + centerX, "centerX");  
        Log.i("centerY =" + centerY, "centerY");  
  
        // Create a new 3D rotation with the supplied parameter  
        // The animation listener is used to trigger the next animation  
        final Rotate3dAnimation rotation = new Rotate3dAnimation(start, end,  
        		centerX, centerY, 310.0f, false);  
        rotation.setDuration(1000);  
        rotation.setFillAfter(true);  
        rotation.setInterpolator(new AccelerateInterpolator());  
        layout.startAnimation(rotation);  
    }     
}  
